home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Games / ADoom / ADoom_src / amiga_main.c < prev    next >
C/C++ Source or Header  |  1998-02-06  |  5KB  |  202 lines

  1. // Emacs style mode select   -*- C++ -*- 
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. //    Main program, simply calls D_DoomMain high level loop.
  21. //
  22. //-----------------------------------------------------------------------------
  23.  
  24. const char amigaversion[] = "$VER: ADoom 0.9 " __AMIGADATE__ ;
  25.  
  26. long __oslibversion = 38;    /* we require at least OS3.0 for LoadRGB32() */
  27. char __stdiowin[] = "CON:20/50/500/130/ADoom";
  28. char __stdiov37[] = "/AUTO/CLOSE/WAIT";
  29.  
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32.  
  33. #include <exec/exec.h>
  34. #include <workbench/startup.h>
  35. #include <workbench/workbench.h>
  36. #include <workbench/icon.h>
  37.  
  38. #include <proto/exec.h>
  39. #include <proto/icon.h>
  40.  
  41. #include "doomdef.h"
  42.  
  43. #include "m_argv.h"
  44. #include "d_main.h"
  45. #include "i_system.h"
  46. #include "m_fixed.h"
  47.  
  48. /**********************************************************************/
  49. extern struct ExecBase *SysBase;
  50.  
  51. int VERSION = 110;
  52.  
  53. int cpu_type;
  54.  
  55. /**********************************************************************/
  56. int main (int argc, char* argv[])
  57.   struct WBStartup *argmsg;
  58.   struct WBArg *wb_arg;
  59.   struct DiskObject *obj;
  60.   char **toolarray, *s;
  61.   int i, p;
  62.  
  63.   /* these command line arguments are flags */
  64.   static char *flags[] = {
  65.     "-forcedemo",
  66.     "-changepitch",
  67.     "-mouse",
  68.     "-joypad",
  69.     "-music",
  70.     "-nosfx",
  71.     "-mmu",
  72.     "-fps",
  73.     "-rotatemap",
  74.     "-maponhu",
  75.     "-rtg",
  76.     "-native",
  77.     "-ehb",
  78.     "-mousepointer",
  79.     "-sega3",
  80.     "-sega6",
  81.     "-pcchecksum",
  82.     "-maxdemo",
  83.     "-nodraw",
  84.     "-noblit",
  85.     "-debugfile",
  86.     "-shdev",
  87.     "-regdev",
  88.     "-comdev",
  89.     "-nomonsters",
  90.     "-respawn",
  91.     "-fast",
  92.     "-devparm",
  93.     "-altdeath",
  94.     "-deathmatch",
  95.     "-cdrom",
  96.     "-playdemo",
  97.     "-avg"
  98.   };
  99.   /* these command line arguments each take a value */
  100.   static char *settings[] = {
  101.     "-screenmode",
  102.     "-taskpriority",
  103.     "-heapsize",
  104.     "-cpu",
  105.     "-forceversion",
  106.     "-file",
  107.     "-timedemo",
  108.     "-skill",
  109.     "-episode",
  110.     "-timer",
  111.     "-statcopy",
  112.     "-record",
  113.     "-playdemo",
  114.     "-timedemo",
  115.     "-loadgame",
  116.     "-config"
  117.     "-turbo",
  118.   };
  119.  
  120.   printf ("%s\n", &amigaversion[6]);
  121.  
  122.   myargc = argc;
  123.   if ((myargv = malloc(sizeof(char *)*MAXARGVS)) == NULL)
  124.     I_Error ("malloc(%d) failed", sizeof(char *)*MAXARGVS);
  125.   memset (myargv, 0, sizeof(char *)*MAXARGVS);
  126.   memcpy (myargv, argv, sizeof(char *)*myargc);
  127.  
  128.   /* parse icon tooltypes and convert them to argc/argv format */
  129.   if (argc == 0) {
  130.     argmsg = (struct WBStartup *)argv;
  131.     wb_arg = argmsg->sm_ArgList;
  132.     if ((myargv[myargc] = malloc(strlen(wb_arg->wa_Name)+1)) == NULL)
  133.       I_Error ("malloc(%d) failed", strlen(wb_arg->wa_Name)+1);
  134.     strcpy (myargv[myargc++], wb_arg->wa_Name);
  135.   }
  136.   if ((obj = GetDiskObject (myargv[0])) != NULL) {
  137.     toolarray = obj->do_ToolTypes;
  138.     for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) {
  139.       if (FindToolType (toolarray, &flags[i][1]) != NULL) {
  140.         myargv[myargc++] = flags[i];
  141.       }
  142.     }
  143.     for (i = 0; i < sizeof(settings)/sizeof(settings[0]); i++) {
  144.       if ((s = FindToolType (toolarray, &settings[i][1])) != NULL) {
  145.         myargv[myargc++] = settings[i];
  146.         if ((myargv[myargc] = malloc(strlen(s)+1)) == NULL)
  147.           I_Error ("malloc(%d) failed", strlen(s)+1);
  148.         strcpy(myargv[myargc++], s);
  149.       }
  150.     }
  151.     FreeDiskObject (obj);
  152.   }
  153.  
  154.   if (argc != myargc) {
  155.     printf ("\nIcon tooltypes translated command line to:\n\n    ");
  156.     for (i = 0; i < myargc; i++)
  157.       printf (" %s", myargv[i]);
  158.     printf ("\n\n");
  159.   }
  160.  
  161.   if ((SysBase->AttnFlags & AFF_68060) != 0)
  162.     cpu_type = 68060;
  163.   else if ((SysBase->AttnFlags & AFF_68040) != 0)
  164.     cpu_type = 68040;
  165.   else if ((SysBase->AttnFlags & AFF_68030) != 0)
  166.     cpu_type = 68030;
  167.   else if ((SysBase->AttnFlags & AFF_68020) != 0)
  168.     cpu_type = 68020;
  169.   else if ((SysBase->AttnFlags & AFF_68010) != 0)
  170.     cpu_type = 68010;
  171.   else
  172.     cpu_type = 68000;
  173.  
  174.   p = M_CheckParm ("-cpu");
  175.   if (p && p < myargc - 1) {
  176.     cpu_type = atoi (myargv[p+1]);
  177.   }
  178.  
  179.   if (cpu_type >= 68060) {
  180.     if ((SysBase->AttnFlags & AFB_68881) != 0) {
  181.       SetFPMode ();  /* set FPU rounding mode to "trunc towards -infinity" */
  182.       FixedMul = FixedMul_060fpu;
  183.       FixedDiv = FixedDiv_060fpu;
  184.     } else {
  185.       FixedMul = FixedMul_060;
  186.       FixedDiv = FixedDiv_040;
  187.     }
  188.   } else {
  189.     FixedMul = FixedMul_040;
  190.     FixedDiv = FixedDiv_040;
  191.   }
  192.  
  193.   p = M_CheckParm ("-forceversion");
  194.   if (p && p < myargc - 1)
  195.     VERSION = atoi (myargv[p+1]);
  196.  
  197.   D_DoomMain ();
  198.  
  199.   return 0;
  200. }
  201.